<script>
import {defineComponent} from 'vue'
import Header from "@/components/Header.vue";
import Main from "@/components/Main.vue";
import Footer from "@/components/Footer.vue";
// 引入eventBus
import eventBus from "@/utils/eventBus";

export default defineComponent({
  name: "App",
  data() {
    return {
      count: 0,
    }
  },
  methods: {
    add() {
      this.count++
      //  eventBus.emit("事件名","值")触发一个事件,事件名是"addCount",要传递的值是this.count
      eventBus.emit("addCount", this.count)
    }
  },
  components: {Header, Main, Footer},
})
</script>

<template>
  <div class="app">
    <button @click="add">+1</button>
    <h1>{{ count }}</h1>
    <Header></Header>
    <Main></Main>
    <Footer></Footer>
  </div>
</template>

<style lang="less"></style>
